package edu.njust.controller;

import edu.njust.pojo.User;
import edu.njust.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/UserController")
public class UserController {


    @Autowired
    @Qualifier("UserServiceImpl")
    private UserService userService;

    //验证账号密码
    @RequestMapping("/login")
    public Map<String, Object> checkIdentity(@RequestParam("userId") String userId, @RequestParam("password") String password){
        Map<String, Object> map = new HashMap<>();
        User user = userService.getUserById(userId);
        if(password.equals(user.getPassword())){
            map.put("msg", "true");
            map.put("user", user);
        }
        else
            map.put("msg", "false");
        return map;
    }

}
